package b3.config
{
	import flash.geom.Point;
	
	public class TownConfig extends BasicConfig
	{
		private const distMax:int = 99999;
		private const directX:Array = [1, -1, 0, 0];
		private const directY:Array = [0, 0, 1, -1];
		
		public var layerIndex:int;
		public var layerName:String;
		public var layerBgrClass:String;
		
		public var sectionConfigs:Array;
		//街区表（X_Y => 街区ID）
		private var sectionMap:Object;
		
		public function TownConfig(layerXML:XML)
		{
			super(layerXML);
			
			sectionConfigs = new Array();
			sectionMap = new Object();
			for (var i:int = 0; i < layerXML.section.length(); i++)
			{
				var sectionConfig:SectionConfig = new SectionConfig(layerXML.section[i])
				sectionConfigs.push(sectionConfig);
				for (var j:int = 0; j < sectionConfig.sectionPoints.length; j++)
				{
					var p:Point = sectionConfig.sectionPoints[j];
					sectionMap[p.x + "_" + p.y] = sectionConfig.index;
				}
			}
		}
		
		public function getSectionIndex(posX:int, posY:int):int
		{
			if (sectionMap[posX + "_" + posY] != null)
				return sectionMap[posX + "_" + posY];
			else
				return -1;
		}
		
	}
}